<template>
  <div class="orders">
    <!-- 面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">商品管理</a></el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 订单详情页 -->
    <el-table
      :data='ordersList.goods'
      class="mt-15"
      border
      style="width: 100%">
      <el-table-column
        type="index"
        label="#"
        width="50">
      </el-table-column>
      <el-table-column

        prop='order_number'
        label="订单编号">
      </el-table-column>
      <el-table-column
        width="80"
        prop='order_price'
        label="订单价格">
      </el-table-column>
      <el-table-column
        width="80"
        prop="order_id"
        label="下单用户">
      </el-table-column>
      <el-table-column
        width="80"
        prop="pay_status"
        label="是否付款">
      </el-table-column>
      <el-table-column
        width="80"
        prop="is_send"
        label="是否发货">
      </el-table-column>
      <el-table-column
        width="120"
        prop="create_time"
        label="下单时间">
      </el-table-column>
      <el-table-column
        label="操作">
        <span slot-scope="scope">
          <el-button type="success" icon="el-icon-edit" circle @click="handleCheck(scope.row)"></el-button>
          <el-button type="danger" icon="el-icon-location-outline" circle></el-button>
        </span>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      class="mt-15"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagenum"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalAll">
    </el-pagination>

  </div>
</template>
<script>
import { getOrdersList } from '@/api'
export default {
  data () {
    return {
      pagenum: 1,
      pagesize: 10,
      totalAll: 0,
      ordersList: []// 页面列表数据
    }
  },
  created () {
    this.initOrderList()
  },
  methods: {
    // 初始化
    initOrderList () {
      getOrdersList({ pagenum: this.pagenum, pagesize: this.pagesize }).then(res => {
        console.log(res)
        this.ordersList = res.data
        this.totalAll = res.data.total
      })
    },
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`)
      this.pagesize = val
      this.initOrderList()
    },
    handleCurrentChange (val) {
      console.log(`当前页: ${val}`)
      this.pagenum = val
      this.initOrderList()
    },
    handleCheck (row) {
      console.log(123)
    }
  }
}
</script>
<style lang="scss" scoped>
  .mt-15{
    margin-top: 15px
  }
</style>
